/*检查文本对象值中只包含数字*/
function isDigit(txtObj){
    if (txtObj.val()=='') return 0;
    var patt = /^[0-9]+$/;
    if (! patt.test(txtObj.val())){
        alert('Here to allow only the importation of digital !');
        txtObj.val('');
        window.setTimeout(function(){txtObj.focus()},5);
    }
}
/*检查文本对象值中只包含字母*/
function isAlpha(txtObj){
    if (txtObj.val()=='') return 0;
    var patt = /^[a-z]+$/i;
    if (! patt.test(txtObj.val())){
        alert('Here to allow only the importation of alpha !');
        txtObj.val('');
        window.setTimeout(function(){txtObj.focus()},5);
    }
}
/*检查文本对象值中只包含字母、数字、下划线*/
function isAlphaDigit(txtObj){
    if (txtObj.val()=='') return 0;
    var patt = /^[a-z0-9_]+$/i;
    if (! patt.test(txtObj.val())){
        alert('Here to allow only the importation of alpha, digital and underlined !');
        txtObj.val('');
        window.setTimeout(function(){txtObj.focus()},5);
    }
}
/*检查文本对象值是否是IPv4地址*/
function isIPv4(txtObj){
    if (txtObj.val()=='') return 0;
    var patt = /^(?:(25[0-5]?|2[0-4]?[0-9]?|1[0-9]{0,2}|[2-9][0-9]?)\.)(?:(25[0-5]?|2[0-4]?[0-9]?|[01][0-9]{0,2}|[2-9][0-9]?)\.){2}(?:(25[0-4]?|2[0-4]?[0-9]?|1[0-9]{0,2}|[2-9][0-9]?))$/i;
    if (! patt.test(txtObj.val())){
        alert('It is not a valid IPv4 address !');
        txtObj.val('');
        window.setTimeout(function(){txtObj.focus()},5);
    }
}
/*检查文本对象值是否是MAC地址*/
function isMAC(txtObj){
    if (txtObj.val()=='') return 0;
    var patt = /^([a-f\d]{2}[:-]{1}){5}[a-f\d]{2}$/i;
    if (! patt.test(txtObj.val())){
        alert('It is not a valid MAC address !');
        txtObj.val('');
        window.setTimeout(function(){txtObj.focus()},5);
    }
}
/*检查文本对象值是否是Email地址*/
function isEmail(txtObj){
    if (txtObj.val()=='') return 0;
    var patt = /^\w+([-+\.]\w+)*@\w+([-\.]\w+)*\.\w+(-.\w+)*$/i;
    if (! patt.test(txtObj.val())){
        alert('It is not a valid E-mail address !');
        txtObj.val('');
        window.setTimeout(function(){txtObj.focus()},5);
    }
}
/*关闭所有文本框对象的输入法*/
$(document).ready(function(){
	$('input[type="text"]').focus(function(){this.style.imeMode='disabled';})
});
